#include "pch.h"
#include "TestDll.h"

AllStruct* _all;

void Init()
{
	if (_all == nullptr)
		_all = new AllStruct();
}

void StructClear()
{
	_all->Clear();
}

void StructAdd(AllStruct::DemoStruct* value)
{
	_all->Add(*value);
}

void StructAdds(AllStruct::DemoStruct* values, int len)
{
	for (int i = 0; i < len; i++)
		_all->Add(values[i]);
}

void StructRead(int id, AllStruct::DemoStruct* readValue)
{
	AllStruct::DemoStruct res = _all->Read(id);
	memcpy(readValue, &res, sizeof(res));
}

void StructReads(int* ids, int len, AllStruct::DemoStruct* items)
{
	std::vector<AllStruct::DemoStruct> res = std::vector<AllStruct::DemoStruct>();
	for (int i = 0; i < len; i++)
		res.push_back(_all->Read(ids[i]));
	//items = &res[0];
	memcpy(items, &res[0], sizeof(AllStruct::DemoStruct) * len);

}

